var o = require("G");
cc.Class({
    extends: cc.Component,
    properties: {
        attendancePrefab: cc.Prefab,
        attendancePrefabScript: "",
        content: cc.Node,
        btn1: cc.Button,
        btn2: cc.Button,
        again: cc.Node,
        againGold: cc.Label,
        at: cc.Node,
        shareLayer: cc.Node,
        shareGold: cc.Label
    },
    onLoad: function () {
        this.init();
    },
    onEnable: function () {
        this.at.active = !0;
    },
    start: function () {
        var t = cc.winSize;
        t.height / t.width >= 1.7 ? (console.log("大于 1.7"), o.Interface.showBannerAD()) : o.Interface.hideBannerAD();
        var e = new Date(),
            n = o.LocalStorage.getData();
        e.toDateString() == n && (this.node.active = !1);
    },
    init: function () {
        var t = o.LocalStorage.getData(),
            e = o.LocalStorage.get("dataTime"),
            n = new Date();
        console.log(t, n.toDateString(), e), t == n.toDateString() ? (this.btn1.interactable = !1,
            this.btn2.interactable = !1, 0 == (e %= 7) && (e = 7)) : e = e % 7 + 1;
        for (var i = 1; i <= 7; i++) {
            var a = cc.instantiate(this.attendancePrefab);
            a.getComponent(this.attendancePrefabScript).init({
                id: i
            }), e > i && a.getComponent(this.attendancePrefabScript).lost(), t == n.toDateString() ? e == i && a.getComponent(this.attendancePrefabScript).lost() : e == i && (this.dataNode = a,
                a.getComponent(this.attendancePrefabScript).now()), a.parent = this.content;
        }
    },
    get: function () {
        this.getGold(1);
    },
    get2: function () {
        o.Interface.showRewardedAD(function () {
            this.getGold(2);
        }.bind(this));
    },
    getGold: function (t) {
        if (cc.director.emit("clickSound"), console.log("11111"), this.dataNode) {
            this.dataNode.getComponent(this.attendancePrefabScript).lost();
            var e = o.LocalStorage.get("gold");
            o.LocalStorage.set("gold", e + this.dataNode.getComponent(this.attendancePrefabScript).gold * t),
                this.initShare(this.dataNode.getComponent(this.attendancePrefabScript).gold * t),
                cc.director.emit("gold");
        }
        var n = new Date();
        o.LocalStorage.setData(n.toDateString());
        var i = o.LocalStorage.get("dataTime");
        i++, o.LocalStorage.set("dataTime", i), this.btn1.interactable = !1, this.btn2.interactable = !1;
    },
    clear: function () {
        o.LocalStorage.setData(0);
    },
    close: function () {
        this.node.active = !1;
    },
    uptime: function () {
        o.LocalStorage.setData(0);
    },
    initShare: function (t) {
        this.shareLayer.active = !0, this.at.active = !1, this.shareGold.string = "x" + t;
    },
    share: function () {
        o.Interface.share(), this.scheduleOnce(function () {
            this.shareLayer.active = !1, this.initAgain(this.dataNode.getComponent(this.attendancePrefabScript).gold);
        }, .3);
    },
    closeShare: function () {
        this.shareLayer.active = !1, this.initAgain(this.dataNode.getComponent(this.attendancePrefabScript).gold);
    },
    initAgain: function (t) {
        this.again.active = !0, this.againGold.string = "x" + t, this.aGold = t;
    },
    againBtn: function () {
        o.Interface.showRewardedAD(function () {
            var t = o.LocalStorage.get("gold");
            o.LocalStorage.set("gold", t + this.aGold), cc.director.emit("gold"), this.closeAgainBtn();
        }.bind(this));
    },
    closeAgainBtn: function () {
        this.again.active = !1, this.node.active = !1;
    }
})